/**
 * Title:        代理数据同步
 * Company:      泛微软件
 */


package checkDetail;

import general.BaseBean;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONObject;

import weaver.general.GCONST;
import weaver.general.OrderProperties;



public class MobileWfSignutureCheck extends BaseBean implements CheckBase  {

    @Override
    public JSONObject checkData(HashMap dataMap) {
        setRecordSet();
        (new BaseBean()).writeLog("MobileWfSignutureCheck  start");

        List resultList = new ArrayList();
        String result = resultOk;
        String sqlStr = "";
        sqlStr +=" select cversion from license ";
        recordSet.executeSql(sqlStr);
        
        if(recordSet.next()){
            String cversion = recordSet.getString("cversion");
            String[] versionArray = cversion.split("\\+");
            if(versionArray.length == 2){
                String version = versionArray[0];
                String kbVersion = versionArray[1];
                if("8.100.0531".equals(version)){
                    //KB81001611以后才进行检测
                    if(kbVersion.compareTo("KB8100161100") >= 0){
                        String hideWfSignuture =null2String(getPropValue("mobile","hideWfSignuture"));
                        if(hideWfSignuture.equals("") || hideWfSignuture.equals("1")){
                            result = resultNeedFix;
                            Map resultMap = new HashMap<String,String>();
                            resultMap.put("showMessage","没有开启手机版的web端流转意见");
                            resultMap.put("buttonname","修复");
                            resultList.add(resultMap);
                        }
                    }
                }
            }
        }
        (new BaseBean()).writeLog("MobileWfSignutureCheck  end");
        return formatReturnJsonCheck(result, resultList,this);
    }

    @Override
    public JSONObject fixData(HashMap dataMap) {
        List resultList = new ArrayList();
        String result = resultOk;
        OrderProperties webSignprop = new OrderProperties();
        webSignprop.load(GCONST.getPropertyPath()+ "mobile.properties");
        webSignprop.put("hideWfSignuture", "0");
        webSignprop.store(webSignprop, GCONST.getPropertyPath() + "mobile.properties");
        result = resultOk;
        if(dataMap!= null && dataMap.get("divid")!= null){
            Map resultMap = new HashMap<String,String>();
            resultMap.put("result",resultOk);
            resultMap.put("fixMessage","修复成功");
            resultMap.put("divid",dataMap.get("divid"));
            resultList.add(resultMap);
            return formatReturnJsonFix(result, resultList,this);
        }
        return checkData(new HashMap());
    }

    @Override
    public String getClassName() {
        return "手机版web端流转意见检测";
    }

    @Override
    public String getClassDesc() {
        return "检测是否开启手机版的web端流转意见（KB81001611以后）";
    }

}



